
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <title>推推推广平台签到</title>
    <link rel="stylesheet" href="__PUBLIC__/task/css/public.css">
    <link rel="stylesheet" href="__PUBLIC__/task/css/signin.css">
    <!-- 弹出层 -->
    <link rel="stylesheet" href="__PUBLIC__/task/css/dialog.css" />
    <script src="__PUBLIC__/task/js/zepto.min.js"></script>
    <script src="__PUBLIC__/task/js/dialog.js"></script>
    <!-- 弹出层 -->
    <script type="text/javascript" src="__PUBLIC__/task/js/clipboard.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/task/js/global.js"></script>
</head>

<body>
<header class="site-header header-fixed">
    <a onclick="window.history.back();" class="back"></a>
    <div class="tit-name">签到</div>
</header>
<div class="top flex flex-align-end flex-pack-center flex-warp">
    <div class="out-1 flex flex-align-center flex-pack-center" id="signIn">
        <div class="out-2 flex flex-align-center flex-pack-center">
            <div class="signBtn">
                <strong id="sign-txt">签到</strong>
                <span>连续<em id="sign-count">0</em>天</span>
            </div>
        </div>
    </div>
</div>
<!-- <div class="tips">今天已签到，获得1个红包</div> -->
<div class="Calendar">
    <div id="toyear" class="flex flex-pack-center">
        <div id="idCalendarPre">&lt;</div>
        <div class="year-month">
            <span id="idCalendarYear">2018</span>年<span id="idCalendarMonth">7</span>月
        </div>
        <div id="idCalendarNext">&gt;</div>
    </div>
    <table border="1px" cellpadding="0" cellspacing="0">
        <thead>
        <tr class="tou">
            <td>日</td>
            <td>一</td>
            <td>二</td>
            <td>三</td>
            <td>四</td>
            <td>五</td>
            <td>六</td>
        </tr>
        </thead>
        <tbody id="idCalendar"></tbody>
    </table>
</div>
<script type="text/javascript" src="__PUBLIC__/task/js/rili.js"></script>
<script language="JavaScript">
    var isSign = true;
    var myday = [1567751952]; //已签到的数组

    var cale = new Calendar("idCalendar", {
        qdDay: myday,
        onToday: function(o) {
            o.className = "onToday";
        },
        onSignIn: function (){
            $$("sign-txt").innerHTML = '已签到';
        },
        onFinish: function() {
            //$$("sign-count").innerHTML = myday.length //已签到次数
            $$("idCalendarYear").innerHTML = this.Year;
//            alert(this.Year);
            $$("idCalendarMonth").innerHTML = this.Month; //表头年份
//            alert(this.Month);
        }
    });
    $$("idCalendarPre").onclick = function() {
        cale.PreMonth();
    }
    $$("idCalendarNext").onclick = function() {
        cale.NextMonth();

    }
    //添加今天签到
    $(function(){
        zidong();
    })

                function zidong() {
                    var userid = {$id};
//        alert(userid);
                        $.post('__PUBLIC__/index/tasks/zidong', {userid: userid}, function (res) {
                            if (res.msg == '1') {
                                var resSignIn = cale.SignIn();
                                if (resSignIn == '1') {
                                $$("sign-txt").innerHTML = '已签到';
                                $('#sign-count').text(res.days);
//                                isSign = true;
                                 }
                            } else {
                                var resSignIn = cale.SignIn();
                                $$("sign-txt").innerHTML = '签到';
                                $('#sign-count').text(res.days);
                                isSign = true;

                            }
                        }, 'json');

                }


    $$("signIn").onclick = function() {
        var userid={$id};
        $.ajax({
            type: "POST",
            url: "__PUBLIC__/index/tasks/do_sign",
            dataType:'json',
            data: {userid:userid},
            success: function(msg){
                console.log(msg);
                if(msg.status=='1'){
//                    var resSignIn = cale.SignIn();
//                    if(resSignIn=='1'){
                    $$("sign-txt").innerHTML = '已签到';
                    $('#sign-count').text(msg.days);
                    isSign = true;
//                    }
                }
            }
        });

//        if(isSign == false) {
//            $.post(
//                    '/index/tasks/do_sign',
//                    {},
//                    function (res) {
//                        console.log(res);
//                        if (res.type == 'success') {
//                            var resSignIn = cale.SignIn();
//                            alert(resSignIn);
//                            if(resSignIn == '1') {
//                                $$("sign-txt").innerHTML = '已签到';
//                                $$("sign-count").innerHTML = parseInt($$("sign-count").innerHTML) + 1;
//                                isSign = true;
//                                message(res.message,res.redirect,res.type);
//                            } else if (res == '2'){
//                                $$("sign-txt").innerHTML = '已签到';
//                                message('今天已经签到了','','error');
//                            }
//                        } else {
//                            message(res.message,res.redirect,res.type);
//                        }
//                    }
//            );
//        } else {
//            message('今天已经签到了','','error');
//        }
    }
</script>



</body></html>